<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Menu Size</title>
<link rel="stylesheet" type="text/css" href="<%= request.getContextPath() %>/css/sp.css"/>

<script type="text/javascript">
	function onClickEdit(objThis){
		var inputAction = document.getElementById("inputAction");
		inputAction.setAttribute("value", "edit");
		var inputID = document.getElementById("menusizeID");
		inputID.setAttribute("value", objThis.alt);
		var form = document.getElementById("formEdit");
		form.submit();
	}

	function onClickDelete(objThis){
		if(confirm("Wants to delete this Menu Category ?")){
			var inputAction = document.getElementById("inputAction");
			inputAction.setAttribute("value", "del");
			var inputID = document.getElementById("menusizeID");
			inputID.setAttribute("value", objThis.alt);
			var form = document.getElementById("formEdit");
			form.submit();
		}
	}
	
	function onClickImgSave(objThis){
		document.getElementById("saveFrom").submit();
	}
	
</script>

</head>
<body>
	<div style="width:100%;" align="center">
		<div class="menu">
			<%@include file="menu.jsp" %>
		</div>
		<div align="center" class="main">
			<%@ include file="header.jsp" %>
			<br>
			<div align="center"><h2>Menu Size</h2></div>	
			<br>			
			<div style="width: 50%; border: 1px solid #000000;">
				<form:form id="saveFrom" method="Post" action="menusize.do" commandName="menusize">
					
					<div style="background-color:#6D7B8D;"><font color="#FFFFFF">Add Menu Size</font></div>
					<input type="hidden" name="action" value="addnew"/>
					<br>
					<table cellspacing="10">
						<tr>
							<td align="right">Size Name :</td><td><form:input path="sizename"/></td>												
						</tr>
						<tr>
							<td align="right">Description :</td><td><form:input path="description"/></td>												
						</tr>
						<tr>
							<td colspan="2" align="center"><form:errors path="sizename" cssClass="error"/></td>
						</tr>
						<tr>
							<td align="left"><a href='menusize.do'><img src="<%= request.getContextPath() %>/images/new.png"/></a></td>				
							<td align="right"><img src="<%= request.getContextPath() %>/images/save.png" style="cursor: pointer;" onclick="onClickImgSave(this)"/></td>
						</tr>
					</table>
				</form:form>
			</div>
			<br>
			<div class="tablelist">
				<form:form id="formEdit" action="menusize.do" method="post">
					<input id="inputAction" name="action" type="hidden"/>
					<input id="menusizeID" name="id" type="hidden"/>									
					<c:if test="${fn:length(listMenuSize) > 0}">
						<table width="100%" cellpadding="10" border="1px solid #000000">
							<tr class="even">
								<th align="center">S. No.</th>
								<th align="center">Size Name</th>
								<th align="center">Description</th>
								<th align="center">Modify</th>
								<th align="center">Delete</th>
							</tr>
							<c:forEach items="${listMenuSize}" var="listMenuSize" varStatus="status">
								<tr class="<c:if test="${status.count % 2 == 0}">evenrow</c:if>">
									<td align="center">${status.count}</td>
									<td align="center">${listMenuSize.sizename}</td>
									<td align="center">${listMenuSize.description}</td>
									<td align="center"><a><img style="cursor: pointer;" src="<%= request.getContextPath() %>/images/edit.png" onclick="onClickEdit(this)" alt="${listMenuSize.menusizeID}"></img></a></td>
									<td align="center"><a><img style="cursor: pointer;" src="<%= request.getContextPath() %>/images/close.png" alt="${listMenuSize.menusizeID}" onclick="onClickDelete(this)"/></a></td>
								</tr>
							</c:forEach>
						</table>
					</c:if>
				</form:form>
			</div>
		</div>
	</div>
</body>
</html>